package com.web.controller;


import com.web.annotation.CurrentUser;
import com.web.domain.Response;
import com.web.entity.UserFeedback;
import com.web.entity.UserInfo;
import com.web.service.UserFeedbackService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@Slf4j
@RestController
@RequestMapping(value = "/app")
public class UserFeedbackController {

    @Autowired
    private UserFeedbackService userFeedbackService;



    @PostMapping("/UserFeedback/addUserFeedback")
    public Response addUserFeedback(@CurrentUser UserInfo info, UserFeedback userFeedback){
        if (StringUtils.isBlank(userFeedback.getContent())){
            return Response.custom().failure("缺少请求参数,请重新核对后再提交!");
        }
        userFeedback.setUserId(info.getUserId());
        userFeedback.setContent(userFeedback.getContent());
        userFeedback.setCreateTime(new Date());
        userFeedback.setModifyTime(new Date());
        userFeedbackService.insertSelective(userFeedback);
        return Response.custom().ok("发布成功！");
    }



}
